#include<bits/stdc++.h>

#define int long long

using namespace std;

typedef pair<int, int> pii;

int d[100005], v[100005], a[100005];
int p[100005];

signed main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int _;
    scanf("%lld", &_);
    while (_--) {
        int n, m, l, x;
        scanf("%lld %lld %lld %lld", &n, &m, &l, &x);
        for (int i = 0; i < n; i++) scanf("%lld %lld %lld", d + i, v + i, a + i);
        for (int i = 0; i < m; i++) scanf("%lld", p + i);
        vector<pii> vec;
        for (int i = 0; i < n; i++) {
            int tmp = v[i] * v[i] + 2 * a[i] * (l - d[i]);
            if (a[i] >= 0) {
                if (tmp > x * x) {
                    if (v[i] > x) vec.emplace_back(d[i], l);
                    else vec.emplace_back((x * x - v[i] * v[i]) / a[i] / 2 + d[i] + 1, l);
                }
            } else {
                if (tmp > x * x) vec.emplace_back(d[i], l);
                else if (v[i] > x) vec.emplace_back(d[i], (v[i] * v[i] - x * x - 1) / (-a[i]) / 2 + d[i]);
            }
        }
        vector<pii> nw;
        for (pii &pa: vec) {
            pa.first = lower_bound(p, p + m, pa.first) - p;
            pa.second = upper_bound(p, p + m, pa.second) - p - 1;
            if (pa.first <= pa.second) nw.push_back(pa);
        }
        printf("%lld ", (int) nw.size());
        sort(nw.begin(), nw.end());
        vec.clear();
        int mn = INT_MAX;
        for (int i = nw.size() - 1; ~i; i--) {
            if (mn > nw[i].second) {
                mn = nw[i].second;
                vec.push_back(nw[i]);
            }
        }
        sort(vec.begin(), vec.end());
        int cnt = 0;
        int lst = -1;
        for (pii pa: vec) {
            if (lst < pa.first) {
                lst = pa.second;
                cnt++;
            }
        }
        printf("%lld\n", m - cnt);
    }
    return 0;
}
